package com.eyaomall.wxmall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eyaomall.wxmall.common.error.BECode;
import com.eyaomall.wxmall.dao.CategoryDao;
import com.eyaomall.wxmall.model.vo.CategoryVO;
import com.eyaomall.wxmall.service.CategoryService;
import com.lycheeframework.core.cmp.kit.PageHTTPObject;
import com.lycheeframework.core.cmp.kit.Pages;
import com.lycheeframework.core.exception.ErrorCodeException;
@Service
public class CategoryServiceImpl implements CategoryService{
	@Autowired
	private CategoryDao categoryDao;
	
	/**
	 * 分页查询类目库
	 * @param categoryVO
	 * @param httpObject
	 * @return
	 */
	public Pages<?> page(CategoryVO categoryVO, PageHTTPObject httpObject) {
		return categoryDao.page(categoryVO, httpObject);
	}

	
	/**
	 * 根据id删除类目
	 * @param id
	 * @return
	 */
	public boolean delete(Integer id) {
		CategoryVO vo=new CategoryVO();
		vo.setId(id);
		vo.setIsDeleted("y");
		return categoryDao.update(vo)>0?true:false;
	}


	/**
	 * 根据id查询类目详情
	 * @param categoryId
	 * @return
	 */
	public CategoryVO queryById(Integer categoryId) {
	
		return (CategoryVO) categoryDao.query("queryById",categoryId);
	}


	/**
	 * 根据shopid获取分类
	 * @param i
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<CategoryVO> queryByShopId(Integer shopid) {
		return categoryDao.list("queryByShopId", shopid);
	}




}
